(load 'ambiente)

;PARAMETROS: fn: Funcion , lae: Lista de Argumentos Evaluados , amb: Ambiente 
(defun aplicar (fn lae amb)
     (if (atom fn) (cond ((eq fn 'car) (caar lae))
                         ((eq fn 'cdr) (cdr (nth 0 lae)))
                         ((eq fn 'list) lae)
                         ((eq fn 'cons) (cons (car lae) (cadr lae)))
                         ((eq fn 'append) (append (car lae) (aplicar 'append (cdr lae) amb)))
                         ((eq fn 'atom) (atom (car lae)))
                         ((eq fn 'numberp) (numberp (car lae)))
                         ((eq fn 'listp) (listp (car lae)))
                         ((eq fn 'symbolp) (symbolp (car lae)))
                         ((eq fn 'null) (null (car lae)))
                         ((eq fn 'length) (length (car lae)))
                         ((eq fn 'eq) (eq (car lae) (cadr lae)))
                         ((eq fn '+) (+ (car lae) (cadr lae)))
                         ((eq fn '-) (- (car lae) (cadr lae)))
                         ((eq fn '*) (* (car lae) (cadr lae)))
                         ((eq fn '/) (/ (car lae) (cadr lae)))
                         ((eq fn '<) (< (car lae) (cadr lae)))
                         ((eq fn '>) (> (car lae) (cadr lae)))
                         ((eq fn 'not) (not (car lae)))
                         ((eq fn 'apply) (apply (car lae) (cadr lae)))
                         ((eq fn 'mapcar) (mapcar (car lae) (cadr lae)))
                         ((eq fn 'funcall) (funcall (car lae) (cadr lae)))
                         
                         ( T (append '(La funcion ) fn '(no esta implementada)))
                      )
         (eval (nth 2 fn) (extenderamb (nth 1 fn) lae amb))
       )
)
 
